var userInfo = null;
$.ajax({
    type: "get",
    url: "/user/queryUserMessage",
    async: false,
    success: function(res){
        //console.log(response);
        if(res.error && res.error == 400){
            location.href = "login.html";
        }
        userInfo = res;
    }
});

$(function(){
    $('#logout').on("click",function(){

        $.ajax({
            type: "get",
            url: "/user/logout",
            success: function (response) {
                if(response.success){
                    mui.toast("退出登录成功");
                    setTimeout(function(){
                        location.href = "index.html";
                    },2000);
                }
            }
        });
    });

    var html = template('userTpl',userInfo);
    $("#userInfoBox").html(html);

});